/**
 * @file Coord.h
 * @author BadFatCat0919 (543015378@qq.com)
 * @brief 坐标类
 */

#ifndef __COORD_H__
#define __COORD_H__

#include "def.h"

/**
 * @brief 坐标
 */
class Coord {
public:
    double x, y;

public:
    Coord(): x(0), y(0) {}
    Coord(double x, double y) : x(x), y(y) {}
    Coord(int x, int y, double scale) : x(x*scale + scale/2), y(y*scale + scale/2) {}
    bool operator==(const Coord &another);
    bool operator!=(const Coord &another);
    Coord operator+(const Coord &another);
    Coord operator-(const Coord &another);
    void set(double x, double y);
    void set(int x, int y);
    void set(const Coord &newValue);
    double toward(Coord target, double whenEqual = 0);
    double distance(Coord target);
    int getCellX(double xScale = MAP_SCALE);
    int getCellY(double yScale = MAP_SCALE);
};

#endif // __COORD_H__
